package db

//postgresql://root@localhost:26257?application_name=cockroach&sslmode=disable
import (
	"log"
	_ "github.com/lib/pq"
	"github.com/go-xorm/xorm"
	"lottery/models"
)
var mMaster *xorm.Engine
func init() {
	postgres:="postgresql://root@localhost:26257/y2t?application_name=cockroach&sslmode=disable"
	//postgres:="postgresql://root@107.150.12.201:26257/bet?application_name=cockroach&sslmode=disable"
	db, err := xorm.NewEngine("postgres",postgres)
	if err !=nil{
		log.Fatal(err)
	}
	db.Sync2(new(models.Bet))
	db.ShowSQL(true)
	db.ShowExecTime(true)
	mMaster=db
	//defer db.Close()
}

type DataBase struct {
	master *xorm.Engine
}

func Master() *xorm.Engine{
	return mMaster
}
